
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

unsigned char buf[1024*1024] = {0};

#define PATH "/dev/test_char_drv_01"

int main()
{
	int i = 0;
    int fd = 0;
	int len = 0;
	int loop_cnt = 100;

	unsigned long long auto_add_cnt = 0;

	fd = open(PATH, O_RDWR);
	if(fd < 0)
	{
		printf("open file %s error!\n", PATH);
		return -1;
	}

	while (--loop_cnt)
	{
		for (i=0; i<sizeof(buf); i++)
		{
			buf[i] = i & 0xFF;
			auto_add_cnt++;
		}
		
		len = write(fd, buf, sizeof(buf));

		printf("write len=%d auto_add_cnt=%lld\n", len, auto_add_cnt);

		sleep(1);
	}

	close(fd);
	
    return 0;
}


